/*
 * Copyright (c) 2010 CCX(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCX(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCX(China) Co.,Ltd.
 *
 * Author: zhaosj
 * Date: 2010-9-6 上午10:50:59
 */
package com.datetime;

import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * @author zhaosj
 *
 */
public class calendarTest {
	
	public static void main(String[] args) {
		
		try {
			String str1 = "2010-09-06 15:01:03:123" ;
			String str2 = "2010-09-06 15:05:10:456" ;
			
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS") ;
			
			Calendar c1 = Calendar.getInstance();
			Calendar c2 = Calendar.getInstance() ;
			
			c1.setTime(df.parse(str1)) ;
			c2.setTime(df.parse(str2)) ;
			
			long l1 = c2.getTimeInMillis() - c1.getTimeInMillis() ;
			System.out.println(l1);
			c1.setTimeInMillis(l1) ;
			System.out.println(df.format(c1.getTime()));
			System.out.println(c2.get(2));
			
			System.out.println(c1.before(c2)) ;
			System.out.println(c1.after(c2));
			
			
		} catch (Exception e) {
			e.printStackTrace() ;
		}
	}

}
